<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <?php
    if (Yii::app()->user->isGuest) {
        ?>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <meta name="language" content="en" />
            <meta http-equiv="X-UA-Compatible" content="IE=edge" />
            <!-- blueprint CSS framework -->
            <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/login.css" media="screen, projection" />
            <title><?php echo CHtml::encode($this->pageTitle); ?></title>

        </head>
        <body>
            <div id="dvEncabezado">
                <table style="width: 100%; height: 100%; padding: 15px;" border="0">
                    <tr>
                        <td valign="bottom" style="font-size: 60px;" onclick="animar()"><?php echo CHtml::encode(Yii::app()->name); ?></td>
                    </tr>
                </table>
            </div>
            <div id="dvLogin">
                <table style="width: 100%; padding: 15px;" border="0">
                    <tr>
                        <td width="200">
                            <form action="<?php echo Yii::app()->createUrl('request/validar', array('hash' => md5(date('HisimY') . rand(1, 100)))); ?>" method="post" id="frmIniciarSesion" name="frmIniciarSesion">
                                <input type="text" placeholder="Usuario" name="txtUsuario" id="txtUsuario" class="inputText" maxlength="10" /><br /><br />
                                <input type="password" name="txtContrasena" id="txtContrasena" placeholder="Contraseña" class="inputText" maxlength="10" /><br /><br />
                                <input type="button" id="cmdEnviar" value="Iniciar sesión" />
                            </form>
                        </td>
                        <td valign="top" style="width: 50%">
                            <div id="dvLoading" style="">
                                <img src="images/328.gif" />
                            </div>
                            <div id="dvMensaje" style="font-size: 15px;">
                                Datos incorrectos, por favor verificalo.
                            </div>
                        </td>
                        <td>
                            <img src="images/logotipo.jpg" />
                        </td>
                    </tr>
                </table>
            </div>
        </body>
        <?php Yii::app()->clientScript->registerCoreScript('jquery'); ?>
        <script type="text/javascript">
            jQuery(function(){
                $("#dvMensaje").hide();
                $("#dvLoading").hide();                
                $('#txtUsuario').focus();                
                                                            
                $('#txtUsuario').keypress(function(e) {
                    if(e.which == 13){
                        $('#txtContrasena').focus();
                    }
                });
                                        
                $('#txtContrasena').keypress(function(e) {
                    if(e.which == 13){
                        validarDatos();
                    }
                });
                                                
                $("#cmdEnviar").click(function(){
                    validarDatos();
                });
                                                        
                function validarDatos(){
                    if($('#txtContrasena').val() != "" && $('#txtUsuario').val() != "") {
                        $("#dvMensaje").hide(); 
                        $("#dvLoading").show();
                        setTimeout("enviarPeticion()",2500);
                    }else{
                        mostrarMensaje("Los campos no pueden ser vacios.")
                    }
                }
            });
                                             
            $('div.funtimes').animate( { 
                left : "+=50", 
                opacity : 0.25 }, 
            300, // duration 
            function() { console.log('realizado'); 
                // función de devolución de llamada 
            });
                                 
                                             
            function animar(){
                if($("#dvEncabezado").height() > 400){
                    $("#dvEncabezado").animate({
                        height:"-=400"
                    }, 500);
                }else{
                    $("#dvEncabezado").animate({
                        height:"+=400"
                    }, 500);
                }
                                
            }
                                                
            function enviarPeticion(){
                //alert("mensaje");
                $("#frmIniciarSesion").submit();
            }
                                            
            function mostrarMensaje(mensaje){
                $("#dvMensaje").html(mensaje);
                $("#dvMensaje").show();
            }
        </script>
        <?php
    } else {
        ?>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <meta name="language" content="en" />

            <!-- blueprint CSS framework -->
            <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/screen.css" media="screen, projection" />
            <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/print.css" media="print" />
            <!--[if lt IE 8]>
            <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/ie.css" media="screen, projection" />
            <![endif]-->
            <link href="logotipo.ico" type="image/x-icon" rel="shortcut icon" />
            <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/main.css" />
            
            <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/form.css" />
             

            <title><?php echo CHtml::encode($this->pageTitle); ?></title>
            <?php Yii::app()->clientScript->registerCoreScript('jquery'); ?>
            <script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/assets/js/scripts.js"></script>
            <script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/assets/js/jquery.maskedinput.js"></script>
            <script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/assets/colorbox/colorbox/jquery.colorbox.js"></script>
            <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/assets/colorbox/colorbox.css" />
            
            <script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/assets/chosen/chosen.jquery.js"></script>
            <link rel="stylesheet" href="<?php echo Yii::app()->request->baseUrl; ?>/assets/chosen/chosen.css" />
            
            <script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/assets/js/tip/jquery.jgrowl_minimized.js"></script>
            <link rel="stylesheet" href="<?php echo Yii::app()->request->baseUrl; ?>/assets/js/tip/jquery.jgrowl.css" />
            
            <script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/assets/js/dt/media/js/jquery.dataTables.js"></script>
            <link rel="stylesheet" href="<?php echo Yii::app()->request->baseUrl; ?>/assets/js/dt/media/css/jquery.dataTables.css" />
            
            <link rel="stylesheet" href="<?php echo Yii::app()->request->baseUrl; ?>/assets/ui/css/ui-lightness/jquery-ui-1.9.2.custom.css" />
            <script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/assets/ui/js/jquery-ui-1.9.2.custom.min.js"></script>
        </head>

        <body>

            <div class="container" id="page">

                <!-- Seccion 1 -->
                <div id="dvOpciones" style="width: 100%; height: 0px;"></div>

                <div id="mainmenu">
                    <div id="mainmenule" style="float: left">
                        <?php
                        $this->widget('zii.widgets.CMenu', array(
                            'items' => array(
                                array('label' => 'Proyectos', 'url' => array('/modulos/index_Proyectos', 'idu'=>Yii::app()->user->id, 'hash'=>Yii::app()->user->hash)),
                                array('label' => 'About', 'url' => array('/site/page', 'view' => 'about')),
                                array('label' => 'Contact', 'url' => array('/site/contact')),
                                //array('label' => 'Login', 'url' => array('/site/login'), 'visible' => Yii::app()->user->isGuest),
                                array('label' => 'Cerrar sesión (' . Yii::app()->user->name . ')', 'url' => array('/request/logout', 'idu'=>Yii::app()->user->id,'hash'=>Yii::app()->user->hash), 'visible' => !Yii::app()->user->isGuest),
                            ),
                        ));
                        ?>
                    </div>
                    <div id="mainmenuri" style="float: right">
                        <ul id="yw0">
                            <li><a href="javascript:mostrarOpciones()">&darr;</a></li>
                            <li><a href="javascript:alert('Bloquear')">&otimes;</a></li>
                        </ul>
                    </div>
                    <div style="clear: both;"></div>
                </div><!-- mainmenu -->
                <?php if (isset($this->breadcrumbs)): ?>
                    <?php /*
                    $this->widget('zii.widgets.CBreadcrumbs', array(
                        'links' => $this->breadcrumbs,
                    ));*/
                    ?><!-- breadcrumbs -->
                <?php endif ?>

                <?php echo $content; ?>

                <div class="clear"></div>

                <div id="footer">
                    Copyright &copy; <?php echo date('Y'); ?>.<br/>
                    <?php //echo Yii::powered(); ?>
                </div><!-- footer -->

            </div><!-- page -->
            
        </body>

        <?php
    }
    ?>
</html>